Skip to content

fix: unblock flux ACR login on self-hosted runners - #706

Merged
alvlia merged 1 commit into
mainfrom
arealmaas/syncroot-flux-azure-auth
Aug 20, 2026
Merged

fix: unblock flux ACR login on self-hosted runners#706
alvlia merged 1 commit into
mainfrom
arealmaas/syncroot-flux-azure-auth

Conversation

@arealmaas

Copy link
Copy Markdown
Contributor

Fixes the ACR login failure that Publish Syncroot artifacts hit after moving to self-hosted runners in #695.

✗ error during login with provider: ... DefaultAzureCredential: failed to acquire a token
    ManagedIdentityCredential authentication failed.
    RESPONSE 400: Unable to load the proper Managed Identity

Why it happened

flux --provider=azure uses the Azure SDK's DefaultAzureCredential, which walks a fixed chain and stops at the first hard failure.

Runner What happens
GitHub-hosted No managed identity endpoint → ManagedIdentityCredential reports unavailable → chain continues → AzureCLICredential picks up the azure/login session
Self-hosted (Container App Job) Azure injects a managed identity endpoint → ManagedIdentityCredential is attempted → job has a user-assigned identity and flux passes no client id → HTTP 400 → SDK treats it as a hard failure and aborts the chain before AzureCLICredential

So azure/login succeeds, and its session is then never consulted.

Worth noting the runner's user-assigned identity has no role assignments either, so it could not push to altinncr even if flux had selected it correctly.

The fix

Clearing the two endpoint variables for this job makes ManagedIdentityCredential report itself unavailable again, restoring exactly the code path GitHub-hosted runners take:

env:
  IDENTITY_ENDPOINT: ""
  MSI_ENDPOINT: ""

Verification

Reproduced both chains against flux 2.6.4 inside the gh-runner:v0.10.0 image, using a mock endpoint returning the same 400:

with endpoint present (self-hosted):
    ManagedIdentityCredential authentication failed. RESPONSE 400   <- chain stops, matches CI log
with endpoint cleared (this PR):
    ManagedIdentityCredential: managed identity timed out
    AzureCLICredential: ERROR: Please run 'az login'                 <- chain reaches the CLI credential

The az login error in the second case is expected locally — there's no Azure session in my container. On the runner azure/login has already established one, which is the whole point.

Scope

This is a workaround in one repo. The durable fix belongs in Altinn/altinn-platform's flux/build-push-image, so flux authenticates explicitly instead of by discovery — proposed separately, since this will hit any team that moves a flux workflow onto these runners.

🤖 Generated with Claude Code

Publish Syncroot artifacts failed on the self-hosted runners with:

  error during login with provider: failed to create provider access
  token for the controller: DefaultAzureCredential: failed to acquire a
  token ... ManagedIdentityCredential authentication failed
  RESPONSE 400: Unable to load the proper Managed Identity

The self-hosted runners are Azure Container App Jobs, which inject a
managed identity endpoint. flux --provider=azure uses the Azure SDK's
DefaultAzureCredential, which walks a fixed chain of credentials. On
GitHub-hosted runners there is no managed identity endpoint, so
ManagedIdentityCredential reports itself unavailable and the chain falls
through to AzureCLICredential, which picks up the session established by
azure/login. On Container Apps the endpoint exists, so it is attempted,
and because the job has a user-assigned identity and flux passes no
client id, the endpoint returns HTTP 400. The SDK treats that as a hard
authentication failure and aborts the chain, so the az login session is
never reached.

Clearing the two endpoint variables for this job makes
ManagedIdentityCredential report unavailable again, restoring the same
code path GitHub-hosted runners take.

Verified by reproducing both chains against flux 2.6.4 in the runner
image: with the endpoint present the chain stops at
ManagedIdentityCredential, and with it cleared the chain reaches
AzureCLICredential.

This is a workaround in one repository. The durable fix belongs in
Altinn/altinn-platform's flux/build-push-image action, so that flux
authenticates explicitly rather than by discovery, and is being proposed
separately.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@alvlia
alvlia merged commit fb538c2 into main Aug 20, 2026
4 checks passed
@alvlia
alvlia deleted the arealmaas/syncroot-flux-azure-auth branch August 20, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants